package pl.cvplus.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_dictionary", schema = "public", catalog = "")
@Entity
public class CpDictionary {
    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String label;

    @javax.persistence.Column(name = "label", nullable = false, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    private Integer languageFk;

    @javax.persistence.Column(name = "language_fk", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getLanguageFk() {
        return languageFk;
    }

    public void setLanguageFk(Integer languageFk) {
        this.languageFk = languageFk;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpDictionary that = (CpDictionary) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (label != null ? !label.equals(that.label) : that.label != null) return false;
        if (languageFk != null ? !languageFk.equals(that.languageFk) : that.languageFk != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (label != null ? label.hashCode() : 0);
        result = 31 * result + (languageFk != null ? languageFk.hashCode() : 0);
        return result;
    }

    private Collection<CpDictionaryValue> cpDictionaryValuesById;

    @OneToMany(mappedBy = "cpDictionaryByDictionaryFk")
    public Collection<CpDictionaryValue> getCpDictionaryValuesById() {
        return cpDictionaryValuesById;
    }

    public void setCpDictionaryValuesById(Collection<CpDictionaryValue> cpDictionaryValuesById) {
        this.cpDictionaryValuesById = cpDictionaryValuesById;
    }
}
